﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WinFormsApp1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
       
        private void button1_Click(object sender, EventArgs e)
        {
            double op1, op2, result=0;
            if (textBox1.Text == "" || textBox2.Text == ""|| comboBox1.Text == "")
            {
                //判断是否两个文本框都输入了数据
                MessageBox.Show(this, "输入错误", "msg", MessageBoxButtons.OK,
                MessageBoxIcon.Information);//有空余项没输入数据弹出提示框
                return;
            }
            op1 = double.Parse(textBox1.Text);//得到两个框框的值并转化为long类型
            op2 = double.Parse(textBox2.Text);

            if (comboBox1.Text == "+")
            {//加法
                result = op1 + op2;
            }
            else if (comboBox1.Text == "-")
            {//减法
                result = op1 - op2;
            }
            else if (comboBox1.Text == "*")
            {//乘法
                result = op1 * op2;
            }
            else if (comboBox1.Text == "/")
            {//除法
                result = op1 / op2;
            }
            textBox3.Text = result.ToString();//设置textBox3的值
        }

        
    }
}
